#ifndef _LAYOUT_H_LULY
#define _LAYOUT_H_LULY
#include "UIObject.h"

// Layout布局
//是HLayout和VLayout的基类
//其实HLayout和VLayout只是相当于Layout的特例而已
//因为，实现的代码都在Layout,只是用常量来区分
// Layout更灵活，可以改变布局的排列方式
class Layout : public UIObject {
 public:
  //内容排列方式
  enum class Arrangement {
    NORMAL,         // NORMAL即不排列
    HORIZONTAL,     //水平向右
    VERTICAL,       //垂直向下
    RE_HORIZONTAL,  // re为相反
    RE_VERTICAL     // re为相反
  };

  //内容对齐的位置
  enum class Alignment {
    LEFT_TOP,
    RIGHT_TOP,
    CENTER,
    CENTER_TOP,
    CENTER_BOTTOM,
    CENTER_LEFT,
    CENTER_RIGHT,
    LEFT_BOTTOM,
    RIGHT_BOTTOM
  };

 private:
 private:
  Layout::Arrangement arrangement = Layout::Arrangement::HORIZONTAL;
  Layout::Alignment alignment = Layout::Alignment::LEFT_TOP;

 protected:
  virtual void init() override;
  virtual void draw() override;
  virtual void drawArea(const Rect& area) override;

 public:
  // @param  arrangement布局的排列方式，如NORMAL,HORIZONTAL,VERTICAL
  Layout(std::string uiObjectId,
         Layout::Arrangement arrangement = Layout::Arrangement::HORIZONTAL,
         Layout::Alignment alignment = Layout::Alignment::LEFT_TOP, int x = 0,
         int y = 0);
  void setArrangement(Layout::Arrangement arrangement) {
    Layout::arrangement = arrangement;
  }
  Layout::Arrangement getArrangement() { return arrangement; }
  void setAlignment(Layout::Alignment alignment) {
    Layout::alignment = alignment;
  }
};

#endif